package com.cbtx.module_sp.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.cbtx.module_sp.R;

/**
 * @author : Lambert
 * date   : 2020/10/25 9:24 PM
 */
public class UnbindDialog extends Dialog {

    Context mContext;
    Bitmap qrCodeBitmap;
    public UnbindDialog(@NonNull Context context, Bitmap qrCodeBitmap) {
        super(context, R.style.MMTheme);
        mContext = context;
        this.qrCodeBitmap = qrCodeBitmap;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);

        Window dialogWindow = getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.width = 550;
        lp.height = 850;
        dialogWindow.setAttributes(lp);

        initView();

        hideBottomButtom();
    }


    private void initView() {
        View contentView = LayoutInflater.from(mContext).inflate(R.layout.unbind_dialog, null);
        ImageView imageView = contentView.findViewById(R.id.mIvQRCode);
        imageView.setImageBitmap(qrCodeBitmap);
        setContentView(contentView);
    }

    private void hideBottomButtom() {
        Window window = getWindow();
        WindowManager.LayoutParams params = window.getAttributes();
        params.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE;
        window.setAttributes(params);

    }
}
